<template>
    <!-- 粉丝数 -->
    <div class="fun">
        <div class="table-head">
             <strong>全部粉丝</strong>
        </div>
        <el-divider></el-divider>
        <!-- 粉丝列表 -->
        <el-table
        :data="tableData"
        style="width:100%; talign:center" >
        <el-table-column
            prop="avatar"
            label="头像"
            width="200px"
            align="center">
            <template width="90" slot-scope="scope">
                 <el-image
                  style="width: 100px; height: 100px"
                  :src="scope.row.avatar"
                 ></el-image>
            </template>  
        </el-table-column>
        <el-table-column
            prop="nickname"
            label="昵称"
            width="500px"
            align="center" >
        </el-table-column>
        <el-table-column
            prop="isAttention"
            label="操作"
            align="center">
            <template slot-scope="scope">
              <el-button size="mini"  @click = "unsubscribe(scope.row.id)">移除</el-button>
            </template>
        </el-table-column>
        </el-table>
    </div>
</template>

<script>
import {getFunList, delect, isAttention} from "@/api/userSubscriptionApi";
export default {
    data() {
        return{
            tableData: [],
            id:sessionStorage.getItem("id"),
            data: true,     
        }
    },
    methods: {
      //移除粉丝
      unsubscribe(index){
        delect({fromId: index, toId: this.id})
          .then((res) => {
              this.$message.success('移除成功成功٩( ๑╹ ꇴ╹)۶');
              this.getFunList()
          }).catch((error) => {
              console.log(error)
          })
      },

      // 获取用户的粉丝
      getFunList() {
          getFunList(this.id) 
          .then((res) => {
          this.tableData = res.data.data.list;
        })
        .catch((error) => {
          console.log(error);
        });
      }
    },
    mounted() {
        this.getFunList();
        // this.isAttention();
        
    },
}
</script>

<style>
.fun{
    width: 1200px;
    margin: 0 auto;
}

</style>
